﻿using System;
using System.Collections.Generic;
using Module.Core.Member;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data;
using Module.Common.Models;
using Module.Core.BusinessLogic;
using Module.Core.Common;
using Module.Core.EntitiesInfo;
using Module.Core.Member;
using Module.Core.Utilities;

namespace Web.Test.ConTrols
{
    public partial class AddMember : System.Web.UI.UserControl
    {
        private string codeMember = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            TreeMemBer tree = new TreeMemBer();
            DataTable dt = null;
            dt = tree.getListMemBer();
        }
        void FillData(MemberInfo info)
        {
            codeMember = MyUtility.MySecurity.GenerateRandomCode();
            info.FullName = txtfullname.Text;
            info.Address = "dia chi";
            info.Email = "Green"+codeMember+"@gmail.com";
            info.Status = Const.show;
            info.DateBirth = DateTime.Now;
            info.Pass = "123456";
            //info.PhoneNumber = txtPhoneNumber.Text;
            info.CodeMemberParent = txtParent.Text.Trim();
            info.CreatedOn = DateTime.Now;
            info.LeftRight = "L";
            info.PriceMount = 0;
            info.Checktype = 0;
            info.CodePosition = "0";
            info.CodeMember = codeMember;
            info.UserName = "";
            info.IsActive = false;
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {

            MemberInfo info = new MemberInfo();

            FillData(info);
            int idMember = MemberBL.Insert(info);
            TreeMemBer treeMemBer = new TreeMemBer();
            treeMemBer.insertMember(codeMember, txtParent.Text.Trim());

            clear();
        }

        protected void clear()
        {
            txtfullname.Text = "";
            txtParent.Text = "";
        }

        
    }
}